package com.bby.user.bean;

import com.bby.common.model.FavoriteGroup;
import com.bby.common.model.UserBusinessInfo;
import com.bby.common.model.UserCustomInfo;
import com.bby.common.model.UserGroup;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
@Accessors(chain = true)
public class UserInfo{
    @Id
    private String userId;
    private String username;
    private String email;
    private String signature;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;
    private String sex;
    private long score;
    private long storageByte;
    private long storageUse;
    /**
     * 收藏书签
     */
    private List<FavoriteGroup> favorites;
    /**
     * 用户组
     */
    private List<UserGroup> userGroups;
    private UserInfo() {
    }

    public UserInfo(UserBusinessInfo businessInfo, UserCustomInfo customInfo) {
        this.userId = businessInfo.getUserId();
        this.storageByte = businessInfo.getStorageByte();
        this.storageUse = businessInfo.getStorageUse();
        this.userGroups = businessInfo.getUserGroups();
        this.favorites = businessInfo.getFavorites();
        this.username = customInfo.username;
        this.email = customInfo.email;
        this.birthday = customInfo.birthday;
        this.sex = customInfo.sex;
        this.signature = customInfo.signature;
    }

}
